package com.shilan.administrator.qintfm.Utils;

/**
 * Created by dllo on 16/1/15.
 * 播放次数数据转换
 *
 */
public class CountToOthers {

    // 转换成"**万"
    public static String getCountToWan(int position) {
        String count;
        // 如果大于10000则转换成"**万"
        if (position > 10000) {
            float a = position;
            float b = a / 10000;
            float c = (float) (Math.round(b * 100)) / 100;
            count = String.valueOf(c) + "万";
            return count;
        } else {
            return String.valueOf(position);
        }
    }

    // 秒转换成0:01:23的格式
    public static String getCountToHour(double duration) {
        String time = null;
        int h = (int)(duration)/ 36000;
        int m = (int)(duration) % 36000 / 60;
        int s = (int)(duration) % 60;
        // 如果小于一小时
        if (h == 0) {
            // 分钟大于9
            if (m > 9) {
                // 秒数大于9
                if (s > 9) {
                    time = m + ":" + s + "";
                } else {
                    time = m + ":" + "0" + s;
                }
            } else if (m <= 9) {
                if (s > 9) {
                    time = "0" + m + ":" + s;
                } else {
                    time = "0" + m + ":" + "0" + s;
                }
            }
        }
        // 如果大于一小时
        else if (h > 0) {
            // 分钟大于9
            if (m > 9) {
                // 秒数大于9
                if (s > 9) {
                    time = "0" + h + m + ":" + s + "";
                } else {
                    time = "0" + h + m + ":" + "0" + s;
                }
            } else if (m <= 9) {
                if (s > 9) {
                    time = "0" + h + "0" + m + ":" + s;
                } else {
                    time = "0" + h + "0" + m + ":" + "0" + s;
                }
            }
        }
        return time;
    }
}
